//
//  NSArray+Additions.m
//  DJFAdditionsModule
//
//  Created by LouKit on 2019/11/12.
//

#import "NSArray+Additions.h"

@implementation NSArray (Additions)

- (NSArray *)dj_deepCopy {
    if (!self) return nil;
    if (![self isKindOfClass:[NSArray class]]) return nil;
    if (self.count == 0) return [self mutableCopy];
    
    NSArray *obj = nil;
    
    @try {
        obj = [NSKeyedUnarchiver unarchiveObjectWithData:[NSKeyedArchiver archivedDataWithRootObject:self]];
    }
    @catch (NSException *exception) {
        NSLog(@"%@", exception);
    }
    return obj;
}

- (id)dj_safeObjectAtIndex:(NSInteger)index{
    if (index < self.count) {
        return [self objectAtIndex:index];
    }else{
        return nil;
    }
}

@end
